var express = require("express"),
    app     = express(),
    http    = require("http"),
    port    = parseInt(process.env.PORT, 10) || 4567;

var server = http.createServer(app).listen(port);
//app.listen(port);
var nowjs = require("now");
var everyone = require('now').initialize(server);

everyone.now.globalData = {
    rooms: [ {  
                name: "FirstRoom",
                id: 1, 
                users: [{name: "dabs", status:"op"}, {name: "sigga", status: "user"}, {name: "nonni", status:"user"} ], 
                messages: ["TODO"] },
              {
                name: "SecondRoom",
                id: 2,
                users:[{name:"dabs", status:"user"},{name: "sigga", status:"user"}, {name:"ingi", status:"user"}],
                messages:["hallo"] },
              {
                name: "ThirdRoom",
                id: 3,
                users:[{name: "nonni",status: "user"}, {name: "konni", status: "op"},{name: "dabs", status:"banned"}],
                messages:["godann daginn", "daginn"]}

                 ],

};



    
app.get("/", function(req, res) {
  res.redirect("/index.html"); 
});

app.configure(function(){
  app.use(express.methodOverride());
  app.use(express.bodyParser());
  app.use(express.static(__dirname + '/public'));
  app.use(express.errorHandler({
    dumpExceptions: true, 
    showStack: true
  }));
  app.use(app.router);
});



app.get( '/rooms', function( req, res ){

  return globalData;
});

app.get( '/rooms/id', function( req, res ){



});

//Bua til nytt herbergi
//app.post( );


//bæta við fleiri aðgerðum